/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fwdisp.content;

import ch.ubique.inieditor.IniEditor;
import fwdisp.MainFrame;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import javax.swing.JOptionPane;

/**
 *
 * @author rbs
 */
public class StatusLabel extends Label{

    private Color bg_color3;
    private Color bg_color2;
    private Color fg_color;

    private int width;

    public StatusLabel(MainFrame main) {
        super(main);
    }

    public StatusLabel(String txt, MainFrame main) {
        super(txt, main);
    }

    @Override
    public void readSettings(String file, String labelName)
    {
        int labelheight;
        int txtsize;
        boolean bold;

        IniEditor imp = new IniEditor(file);
        try {
            imp.load(file);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Fehler beim Lesen der Datei. Bitte die settings.ini neu herunterladen.");
            System.exit(-2);
        }

        labelheight = Integer.decode(imp.get(labelName, "labelHeigt"));
        fg_color = Color.decode(imp.get(labelName, "FgColor"));
        bg_color3 = Color.decode(imp.get(labelName, "BgColor3"));
        bg_color2 = Color.decode(imp.get(labelName, "BgColor2"));
        txtsize = Integer.decode(imp.get(labelName, "TxtSize"));
        bold = Boolean.valueOf(imp.get(labelName, "bold"));

        setSize(width, labelheight);
        setOpaque(false);
        setForeground(fg_color);
        if (bold)
            setFont(new Font("serif", Font.BOLD, txtsize));
        else
            setFont(new Font("serif", Font.PLAIN, txtsize));
    }

    public void SetStatus2()
    {
        setForeground(fg_color);
        setBackground(bg_color2);
        setBorder(Color.black, 3);
        setOpaque(true);
    }

    public void SetStatus3()
    {
        setForeground(fg_color);
        setBackground(bg_color3);
        setBorder(Color.black, 3);
        setOpaque(true);
    }

    public void SetStatusInactive()
    {
        setForeground(Color.gray);
        setOpaque(false);
    }

    public void SetWidth(int width)
    {
        this.width = width;
    }



}
